<template>
  <!-- header -->
  <div>
  <div class="header">
    <div class="image">
      <img src="../assets/image.png" />
    </div>
  </div>
  <!-- header -->
  <!-- body -->
  <div class="main">
    <div class="img1">
      <div class="login">
        <!-- 登陆类型 -->
        <!-- <div id = "app"> -->
        <div class="img2">
          <h1 class="login_title">Welcome to visit</h1>
          <!-- 专家登陆-->
          <div :class="{ on: loginWay }">
            <section class="login_message">
              <input type="text" maxlength="11" placeholder="用户名" v-model="account.admin_username"/>
            </section>
            <section class="login_verfication">
              <input
                type="text"
                maxlength="11"
                minlength="6"
                placeholder="密码"
                v-model="account.admin_pass"
              />
            </section>
             <div class="login_bottom">
            <el-button @click="login" class="login_bottom_btn">登陆</el-button>
          </div>
          </div> 
        </div>
      </div>
    </div>
  </div>
  </div>
</template>

<script>
export default {
	components: {
		loginHeader,
		loginFooter
	},
	data() {
		return {
			account: {
				admin_username: "",
				admin_pass: ""
			},
			userToken: ""
		};
	},
	methods: {
		async login() {
			if (this.account.admin_username === "" || this.account.admin_pass === "") {
				alert("账号或密码不能为空");
			} else {
				var data = await this.$http.post('/validateAdminLogin',JSON.stringify(this.account));
				console.log("postData:"+JSON.stringify(data.message)+" "+JSON.stringify(data.state));
				var userdata;

				if (this.account.admin_username == "admin") {
					userdata = {
						nickname: data.data.admin_username,
						rolename: "admin"
					};
				} else if (this.account.admin_username == "user") {
					userdata = {
						nickname: data.data.admin_username,
						rolename: "user"
					};
				} else if (this.account.admin_username == "editor") {
					userdata = {
						nickname: data.data.admin_username,
						rolename: "editor"
					};
				} else {
					return;
				}
				this.$store.commit("login", JSON.stringify(userdata));
				console.log(JSON.stringify(userdata))
				this.$router.push("./");
			}
		},
		test() {}
	}
};
</script>

<style>
/* 背景 */
.img1 {
  background-size: 100% 100%;
  background: url("../assets/15.jpg") center center no-repeat;
  left: 0px;
  height: 80%;
  position: fixed;
  width: 100%;
}
.img2 {
  position: absolute;
  background-size: 10% 10%;
  background: url("../assets/15.jpg") center center no-repeat;
  height: 51.6%;
  position: fixed;
  width: 27.2%;
}

/* 头部 */

.header {
  position: absolute;
  line-height: 40px;
  top: 0px;
  left: 0px;
  right: 0px;
  height: 100px;

  background-color: #ffffff;
}
/* 内容 */
.main {
  position: absolute;
  top: 50px;
  left: 0px;
  height: 50px;
  bottom: 500px;
  right: 0px;
  /* 距离右边0像素 */
  padding: 10px;
  overflow-y: auto;
  /* 当内容过多时y轴出现滚动条 */
  /* background-color: red; */
}
.main .login {
  position: absolute;
  top: 150px;
  left: 1200px;
  height: 500px;
  width: 522px;
  bottom: 500px;
  right: 0px;
  background-color: #ffffff;
  border-radius: 2px;
  /* 距离右边0像素 */
  border: 3px solid #000;
}

.header .image {
  position: center;
  line-height: 0px;
  top: 0px;

  height: 0px;
  background-color: #ffffff;
}
/* <!-- 登陆类型 --> */
.divcss5 {
  border-left: 1px solid #00f;
}
.login_title {
  color: green;
  text-align: center;
}
.login_header_title {
  clear: both;
}
.title1 {
  color: green;
  margin-left: 120px;
  margin-bottom: 15px;
  float: left;
}
.title2 {
  color: green;
  margin-right: 97px;
  margin-bottom: 15px;
  float: right;
}
.login_message {
  float: left;
  margin-left: 120px;
  margin-bottom: 20px;
}
.login_message input {
  width: 280px;
  height: 30px;
}
.get_verfication {
  position: absolute;
  border: none;
  outline: none;
  top: 135px;
  left: 380px;
}
.login_verfication input {
  width: 280px;
  height: 30px;
}
.login_verfication {
  float: left;
  margin-left: 120px;
  margin-bottom: 20px;
}
.login_hint {
  float: left;
  margin-left: 120px;
  width: 280px;
}
.login_hint a {
  text-decoration: none;
}
.on {
  display: none;
}
.login_bottom p {
  
  float: left;
  margin-left: 230px;
  margin-top: 15px;
}
.login_bottom_bm {
 
  position: center;
  border: none;
  float: cleft;
  margin-top: 40px;
  margin-left: 120px;
  
width: 280px;
  height: 50px;
}

.login_bottom_btn {
 
  position: center;
  background-color: #55aaff;
  /* border: none; */
 
  float: left;
  margin-top: 40px;
  margin-left: 120px;
  width: 280px;
  height: 50px;
}

/* 字体 */
.p1 {
  font-family: "Times New Roman", Times, serif;
  color: #ff5500;
}

/* <!-- 登陆类型 --> */
</style>
